package com.smartplatform.controller;

import com.smartplatform.dto.R;
import com.smartplatform.pojo.SysScene;
import com.smartplatform.service.SysSceneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 咕唧
 * @Date 2022/5/31 17:57
 * @Version 1.0
 */
@RestController
@RequestMapping("/scenes")
public class SysSceneController {

    private SysSceneService sysSceneService;

    @Autowired
    public void setSysSceneService(SysSceneService sysSceneService) {
        this.sysSceneService = sysSceneService;
    }

    @PostMapping("/scene")
    public R addScene(@RequestBody SysScene sysScene) {
        sysSceneService.addSysScene(sysScene);
        return R.setOK();
    }

    @GetMapping("/scenes")
    public R findAllSceneByUserId() {
        //查询所有的场景
        List<SysScene> sceneList = sysSceneService.findAllSceneByUserId();
        return R.setOK(sceneList);
    }
}
